package algorithm.doublePointer;

import java.util.Arrays;

// 移动零
public class LC283 {
    public void moveZeroes(int[] nums) {
        for (int cur = 0, dest = -1; cur < nums.length; cur++) {
            if (nums[cur] != 0) {
                dest++;
                int tmp = nums[dest];
                nums[dest] = nums[cur];
                nums[cur] = tmp;
            }
        }
    }

    public static void main(String[] args) {
        LC283 lc283 = new LC283();
        int[] nums = {0, 1, 0, 2, 3, 0};
        lc283.moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }
}
